
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <title>找回密码</title>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <!-- Custom Theme files -->
    <link href="/css/style.css" rel='stylesheet' type='text/css' />
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <!-- Custom Theme files -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="Hotel Deluxe Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <!--webfont-->
    <link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
    <!--<link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>-->
    <script type="text/javascript" src="/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="/js/login.js"></script>
    <!--Animation-->
    <script src="/js/wow.min.js"></script>
    <link href="/css/animate.css" rel='stylesheet' type='text/css' />
    <script>
      //  new WOW().init();
    </script>
</head>
<body>
<style>
    .to {
        width: 50%;
    }
    .to input {
        width: 100%;
    }
    #verify_refresh {
        font-size: 1.5em;
    }
</style>
<script>
    var messageData;
    var wait = 60; // 短信验证码120秒后才可获取下一个
    /**
     * 获取验证码
     * @param that
     */
    function getMsgNum(that) {
        var phoneNumber = $('#tel').val();
        var username = $("#username").val()
        setButtonStatus(that); // 设置按钮倒计时
        $.ajax({
            url: "/verifycode/get_code?username=" + username + "&memPhone=" + phoneNumber, // 后台短信发送接口
            type: 'GET',
            data: {},
            async: false, //false 同步
            success: function (result) {
                if(result.success == true) {
                    messageData = result.data;
                }else {
                    alert("发送短信失败，" + "错误信息:" + result.data);
                }
            }
        });

    }
    /**
     * 设置按钮状态
     */
    function setButtonStatus(that) {
        if (wait == 0) {
            that.removeAttribute("disabled");
            that.value="免费获取验证码";
            wait = 60;
        } else {
            that.setAttribute("disabled", true);
            that.value=wait+"秒后可以重新发送";
            wait--;
            setTimeout(function() {
                setButtonStatus(that)
            }, 1000)
        }
    }
    /**
     * 注册按钮
     */
    function validateNum() {
        var data = {
            msgNum: inputMsgNum,
            tamp: messageData.tamp,
            hash: messageData.hash
        };
        $.ajax({
            url: httpurl + '/validateNum', // 验证接口
            type: 'POST',
            dataType: 'json',
            contentType: "application/json",
            data: JSON.stringify(data),
            async: false, //false 同步
            success: function (data) {
                //业务处理
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest.status);
                console.log(XMLHttpRequest.readyState);
                console.log(textStatus);
            }
        });
    }
</script>
<div class="living_middle wow fadeInUp" data-wow-delay="0.4s" style="padding-bottom: 300px">
    <div class="container">
        <h2>修改用户信息</h2>
        <form>
            <div class="to" style="margin: auto">
                <input type="text"  name="username" id="username" placeholder="用户名">
                <input type="tel"  name="tel" id="tel" placeholder="电话号码">
                <input type="text"  name="verifycode" id="verifycode" placeholder="验证码">
                <input type="button" class="btn btn-block btn-flat" id="verify_refresh" onclick="getMsgNum(this)" value="免费获取验证码">
                <div class="clearfix"></div>
            </div>
            <div class="form-submit1">
                <br>
                <input name="register"  id="register" type="submit"  value="找回密码">   <!--id=submit-->
                <a href="/"><input name="register"  type="button"  value="返回首页"></a>
            </div>
            <div class="clearfix"></div>
        </form>
    </div>
</div>
<script>
    $('#register').click(function (event) {
        event.preventDefault();
        var phoneNumber = $('#tel').val();
        var username = $("#username").val()
        var verifycode = $("#verifycode").val()
        $.ajax({
            url: '/user/findpsw', // 验证接口
            type: 'POST',
            data: {'username':username,
                'verifycode': verifycode
            },
            async: false, //false 同步
            success: function (data) {
                if (data.success == true) {
                    alert("你的密码是：" + data.password);
                } else {
                    alert("验证码错误")
                }
            }
        });

        return false
    })
</script>
<div class="footer" style="height: 600px">
    <div class="container"></div>
    <div class="footer_top">
        <h3>&nbsp;</h3>
        <h3>四川大学酒店订购系统</h3>
        <h3>Team 22</h3>
    </div>
</div>
</body>

</html>